<?php session_start();
include("authentication.php");
require_once('../includes/conn.php'); 
require_once('../includes/settings.inc.php');
include("../includes/functions_emagineit.php");
$obj = new EmagineIT();

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if($_POST["publish"]) $publish = 1;
else $publish = 0;

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) 
{
	
	
	$modified= date("Y-m-d h:i:s");
	
	
	
	$user_intrst_cat = "";
	$user_intrst_cat1=$_REQUEST['user_intrst_cat'];
	if ($user_intrst_cat1){
	 foreach ($user_intrst_cat1 as $t)
	 {
		
		$user_intrst_cat  = $user_intrst_cat."".$t."-"; 
	 }
	}
	
	
	
			
						$SQL1 ="update `user_profiles` set `modified` = '".$modified."', first_name = '".$_REQUEST['first_name']."', last_name = '".$_REQUEST['last_name']."', middle_name = '".$_REQUEST['middle_name']."', password = '".$_REQUEST['password']."', gender_id = '".$_REQUEST['gender_id']."',  dob = '".$_REQUEST['dob']."', about_me = '".$_REQUEST['about_me']."', address = '".$_REQUEST['address']."', city_id = '".$_REQUEST['city']."', state_id = '".$_REQUEST['state']."', country_id = '".$_REQUEST['country']."', zip_code = '".$_REQUEST['zip_code']."', user_email = '".$_REQUEST['user_email']."', user_mobile = '".$_REQUEST['user_mobile']."', user_phone = '".$_REQUEST['user_phone']."', user_intrst_cat = '".$user_intrst_cat."', user_dp_lower = '".$_REQUEST['user_dp_lower']."', user_dp_upper = '".$_REQUEST['user_dp_upper']."' where id = '".$_REQUEST["code"]."'";
						$Result2 = mysql_query($SQL1) or die($SQL1);
					
	
	 //$Result1 = mysql_query($SQL) or die($SQL);
	 
	  echo "<script language='javascript'>
			alert('Profile edited successfully!');
			window.location = 'container.php?vu=viewclients&for=client';
			</script>";  	
		
}



// For data retrieval
$s1 = "select * from user_profiles where id = '".$_REQUEST["code"]."'";
$q1 = mysql_query($s1) or die($s1);
$rs = mysql_fetch_array($q1); 
	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?=$site_name?> - Admin Panel</title>
<META NAME="ROBOTS" CONTENT="NOARCHIVE">
<META NAME="ROBOTS" CONTENT="NOINDEX">
<META NAME="ROBOTS" CONTENT="NOIMAGEINDEX">
<META NAME="ROBOTS" CONTENT="NOFOLLOW">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
	// <![CDATA[
	var myMenu;
	window.onload = function() {
		myMenu = new SDMenu("my_menu");
		myMenu.init();
	};
	// ]]>
	function change_status(type)
	{
		if(type == '1')
		{
			document.getElementById("email_details").style.display = 'inline';
		}
		else
		if(type == '0')
		{
			document.getElementById("email_details").style.display = 'none';
		}
	}
</script>
<script type="text/javascript" src="sdmenu/sdmenu.js"></script>
<script language="javascript" type="text/javascript" src="../includes/validate.js"></script>
<script type="text/javascript" src="<?=$path?>js/jsapi.js"></script>
<link href="css/styleer.css" rel="stylesheet" type="text/css">
<link href="css/stylesheet.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="sdmenu/sdmenu.css" />
<link href="<?=$path?>css/viterumCSS.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="<?=$path?>js/globale_jsfile.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function change_language(typ)
{
	//alert(typ);
	if(typ == 'show_en')
	{
		document.getElementById("show_ja").style.display = "none";
		document.getElementById("show_en").style.display = "none";
		document.getElementById("main_body_ajax_show_post_top").style.display = "inline";
		setTimeout("document.getElementById('main_body_ajax_show_post_top').style.display = 'none';", 2000);
		setTimeout("document.getElementById('show_en').style.display = 'inline';", 2000);
		document.getElementById("language").value = 'en';
	}
	else
	if(typ == 'show_ja')
	{
		document.getElementById("show_ja").style.display = "none";
		document.getElementById("show_en").style.display = "none";
		document.getElementById("main_body_ajax_show_post_top").style.display = "inline";
		setTimeout("document.getElementById('main_body_ajax_show_post_top').style.display = 'none';", 2000);
		setTimeout("document.getElementById('show_ja').style.display = 'inline';", 2000);
		document.getElementById("language").value = 'ja';
	}
	//alert(document.getElementById("language").value);
}
</script>
</head>
<body >
<table width="987" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="987"><img src="<?=$path?>images/spacer.gif" width="100" height="25" /></td>
  </tr>
  <tr>
    <td><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><img src="<?=$path?>images/index_03.gif" width="46" height="57" alt="" /></td>
        <td><img src="<?=$path?>images/index_04.gif" width="895" height="57" alt="" /></td>
        <td><img src="<?=$path?>images/index_05.gif" width="46" height="57" alt="" /></td>
      </tr>
      <tr>
        <td background="<?=$path?>images/index_07.gif"><img src="<?=$path?>images/spacer.gif" width="46" height="100" /></td>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>&nbsp;</td>
          </tr>
      
      <tr>
        <td align="left" valign="top">
		
		
		
		
		
		
		
		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="16%" valign="top"><table width="80%"  border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><table width="80%"  border="0" cellspacing="0" cellpadding="0">
                      
                      <tr>
                        <td valign="top"><?php include("leftnavigation.php");?></td>
                      </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td height="6"><img src="images/spacer.gif" width="1" height="1"></td>
                  </tr>
                  
                  
                </table></td>
                <td width="84%" valign="top"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="233" valign="top" class="blueBarborder2"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
					
                      <tr>
                        <td height="31" class="blueBarborder"><table width="97%"  border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td class="blackTxt"><?=$site_name?> - Admin Panel </td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td height="202" valign="top" bgcolor="#dbedf1"><table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td height="8"><img src="images/spacer.gif" width="1" height="1"></td>
                          </tr>
                          <tr>
                            <td>
		<form name="RTEDemo" action="<?php echo $editFormAction; ?>" method="post" onSubmit="return submitForm();" enctype="multipart/form-data">				
			<table width="100%" align="left" cellpadding="0" cellspacing="0">
                                <td colspan="3" valign="top"><div id="show_en"><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="29" colspan="3"><h3>&nbsp;</h3></td>
  </tr>
  
  				  
				  
				  
  <tr>
    <td width="1%">&nbsp;</td>
    <td width="29%">Title*: </td>
    <td width="70%"><input name="cpn_title" type="text" id="cpn_title" size="45" value="<?=$rs['first_name']?>" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td> Details: </td>
    <td>
	<textarea name="cpn_detail" id="cpn_detail"><?=$rs['cpn_detail']?></textarea>
	</td>
  </tr>
  
  
  
  <tr>
    <td>&nbsp;</td>
    <td>Country *:</td>
    <td>
	<select id="country" name="country" style="width:310px;">
   
	
	<?
		$sc = "select * from countries";
		$qc = mysql_query($sc) or die($sc);
		while($rqc = mysql_fetch_array($qc))
			{?>
			<option value="<?=$rqc["id"]?>" <? if($rqc["id"] == $rs['country_id'] ) { echo "selected"; } ?>><?=$rqc["name"]?></option>
			<? }
		?>
	</select>	</td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td>State *: </td>
    <td>
  <select name="state" id="state" style="width:310px;">
 
   
	
	<?
		$sc2 = "select * from states";
		$qc2 = mysql_query($sc2) or die($sc2);
		while($rqc2 = mysql_fetch_array($qc2))
			{?>
			<option value="<?=$rqc2["id"]?>" <? if($rqc2["id"] == $rs['state_id'] ) { echo "selected"; } ?> ><?=$rqc2["name"]?></option>
			<? }
		?>
		
   </select>  </td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td>City *:</td>
    <td>
  <select style="width:310px;" name="city">
  
  <?
		$sc3 = "select * from cities";
		$qc3 = mysql_query($sc3) or die($sc3);
		while($rqc3 = mysql_fetch_array($qc3))
			{?>
			<option value="<?=$rqc3["id"]?>" <? if($rqc3["id"] == $rs['city_id'] ) { echo "selected"; } ?> ><?=$rqc3["name"]?></option>
			<? }
		?>
		
  
  
  </select>
  
  
  </td>
  </tr>
  
  
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>Categories of interest :</td>
    <td valign="bottom">
	
	<? 
	$intrst = explode('-', $rs["user_intrst_cat"], -1);
		
	?>
	
	<select name="user_intrst_cat[]" id="user_intrst_cat" multiple="multiple" style="width:315px">
	<?
		$sc = "select * from categories where cat_status = '1'";
		$qc = mysql_query($sc) or die($sc);
		while($rqc = mysql_fetch_array($qc))
			{
				
			?>
			<option value="<?=$rqc["cat_id"]?>" <? foreach ($intrst as $v) 
				{ if($rqc["cat_id"] == $v) { echo "selected"; }  }?> ><?=$rqc["cat_name"]?></option>
			<? 
				
			}
		?>
	</select>&nbsp;(hold down ctrl key for multiple selection)	</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>Price Range *: </td>
    <td> <input name="user_dp_lower" type="text" id="user_dp_lower" size="10" maxlength="10" value="<?=$rs["user_dp_lower"]?>" /> 
    &nbsp;to&nbsp;<input name="user_dp_upper" type="text" id="user_dp_upper" size="10" maxlength="10" value="<?=$rs["user_dp_upper"]?>" /> 
    (SEK)  </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
 
 
</table>
								  </div><div id="show_ja" style="display:none;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
								 
								  
   								
								  
                           
</table>
</td>
                                 
                             
                                <tr valign="baseline">
                                  <td nowrap align="right">&nbsp;</td>
                                  <td colspan="2">
								  <input name="submit" type="submit" value="Save Page">
								  <input name="language" type="hidden" id="language" value="en">
             					  <input name="code" type="hidden" id="code" value="<?php echo $_REQUEST['code']?>" />
								  <input name="for" type="hidden" id="for" value="<?php echo $_REQUEST['for']?>" />
              					  <input name="new_page" type="hidden" id="code" value="<?php echo $_REQUEST['vu']?>" />			  </td>
                                </tr>
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                              </table><input type="hidden" name="MM_insert" value="form1"></form>
														</td>
                          </tr>
                        </table></td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
             </table>
			 
		
		
		
		
		
		
		
		
		
		
		
		
		</td>
      </tr>
     
              
              
            </table></td>
        <td background="<?=$path?>images/index_21.gif"><img src="<?=$path?>images/spacer.gif" width="46" height="100" /></td>
      </tr>
      <tr>
        <td><img src="<?=$path?>images/index_37.gif" width="46" height="48" alt="" /></td>
        <td background="<?=$path?>images/index-over_38.gif">&nbsp;</td>
        <td><img src="<?=$path?>images/index_40.gif" width="47" height="48" alt="" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><img src="<?=$path?>images/index_41.gif" width="987" height="52" alt="" /></td>
  </tr>
</table>
</body>
</html>
